package com.hsylient.servlet;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet implements Servlet {

    private ServletConfig servletConfig;

    @Override
    public void init(ServletConfig config) throws ServletException {
        this.servletConfig = config;
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        ServletContext servletContext = servletConfig.getServletContext();
        System.out.println(servletContext.getContextPath());
        System.out.println("servletContext.getEffectiveMajorVersion() = " + servletContext.getEffectiveMajorVersion());
        System.out.println("servletContext.getMajorVersion() = " + servletContext.getMajorVersion());
        servletContext.setAttribute("name", "黄涛");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}